home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / toadcr11.zip / TOADCRLF.DOC < prev   
Text File  |  1989-08-04  |  3KB  |  73 lines

  1. TITLE TOADCRLF Unix <- > DOS EOL converter
  2.  
  3. Usage:  CRLF [-r] file1 [>output]
  4.     -r    Convert from DOS CR/LF End Of Line (EOL) to Unix LF EOL.
  5.         Default output is STDOUT (e.g., redirectable).
  6.  
  7. Written to replace the C version by Steve Creps (which was a slug)
  8.  
  9. Unix text files normally have a LineFeed (ASCII 0AH) end of line.
  10. DOS text files normally have a CR/LF (ASCII 0DH 0AH) end of line.
  11. This utility will convert one type text file to the other.
  12.  
  13. If you use the -r switch, CRLF assumes the target input file
  14. is a DOS text file.  It'll scan the first buffer of text for CR characters.
  15. If it doesn't find any .. you could be fiddling a Unix-type text file!
  16. CRLF will give you a warning and a chance to abort.
  17.  
  18. If you aren't using the -r switch, CRLF assumes the target input file
  19. is a Unix text file.  It'll scan the first buffer of text for CR characters.
  20. If it DOES find a CR .. you could be fiddling a DOS-type text file!
  21. CRLF again will give you a warning and a chance to abort.
  22.  
  23. Note:  Since output is via DOS's normal redirection, DOS is creating the
  24. output.  If it's a file .. and you abort .. you will have an empty file
  25. on the output path you designated.
  26.  
  27. And, of course, with redirection, CRLF will gleefully overwrite anything
  28. you point it at for output!  On your own head be it!
  29.  
  30. Error trapping:  There's only a minimum of file read/write error trapping.
  31. You'll get some simple error messages if there are any problems.
  32. CRLF will return ERRORLEVEL per what DOS returned from the file read/write.
  33. If there are no errors:  ERRORLEVEL = 0.
  34.  
  35.  
  36. Given to the public domain, 7 Jul 89
  37.  
  38. David Kirschbaum
  39. Toad Hall
  40. kirsch@braggvax.ARPA
  41.  
  42. v1.1, 3 Aug 89
  43.  - Bug report from Erich Neuwirth <A4422DAB%AWIUNI11.BITNET@CUNYVM.CUNY.EDU>
  44.    Unix -> DOS conversion breaks down at the BUFFSIZE boundary.
  45.    Found bug when writing output buffer .. a constant CR or LF (in AH)
  46.    was being lost by destroying AX during the output write.
  47.    Fixed.  Thanks, Erich.
  48.  
  49.    While I was at it (no functional changes .. just tweaks):
  50.  
  51.  - Relocated dynamic file buffers to overlay the startup code and messages.
  52.  
  53.  - Changed input and output buffer sizes to eliminate the multiple tests
  54.    of the ES:DI output buffer pointer during conversion.
  55.  
  56.    Now we read an input buffer-full, process it to the output buffer,
  57.    and then write the full output buffer .. not worrying about overrunning
  58.    the output buffer end (and our stack!)
  59.  
  60.    This overrun problem would only arise during Unix --> DOS conversions
  61.    (where output is longer than input).
  62.    There's no telling just HOW much longer the output will be than the
  63.    input .. worst case is input * 2 (a file of all CRs converted to
  64.    a file of all CR/LFs).
  65.  
  66.    Assuming worst case, we're making our output buffer TWICE the size
  67.    of the input buffer (most unlikely .. but still ..).
  68.  
  69.    Surprisingly, we've gained no significant speed!  The more frequent
  70.    input file reads offset the increase in processing speed .. sigh ...
  71.  
  72.    Toad Hall
  73.